#include "MarsPrecompile.h"
#include "MarsCLCommandQueue.h"
#include "MarsCLContext.h"
#include "MarsCLDevice.h"

using namespace GP;
using namespace Core;

bool CLCommandQueue::Create()
{
	cl_int status = CL_SUCCESS;
	cl_command_queue_properties prop = 0;

	const CLContext* pContext = ( const CLContext* ) m_context.GetPointer();
	const CLDevice* pDevice = ( const CLDevice* )pContext->GetDevice().GetPointer();

	m_commandQueue = clCreateCommandQueue( pContext->GetNativeContext(), pDevice->GetNativeDeviceId(), prop, &status );

	if ( status != CL_SUCCESS )
	{
		// TODO: log error
		// CHECK_OPENCL_ERROR( status, "clCreateCommandQueue failed.");
		return false;
	}

	m_bInit = true;

	return true;
}